from typing import Any, Optional
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy_crud_plus import CRUDPlus

from modules.system.models.staff import Salesperson
from modules.system.schemas.staff_schemas import StaffCreate, StaffUpdate
from modules.system.schemas.staff_schemas import StaffCreate, StaffUpdate
from modules.system.params.staff_params import StaffQuery


class StaffRepository(CRUDPlus[Salesperson]):
    async def get_by_id(self, db: AsyncSession, pk: int):
        return await self.select_model(db, pk)

    async def create(self, db: AsyncSession, data: StaffCreate) -> Salesperson:
        return await self.create_model(db, data)

    async def update(self, db: AsyncSession, pk: int, data: StaffUpdate) -> Optional[Salesperson]:
        await self.update_model(db, pk, data)
        return await self.select_model(db, pk)

    async def delete(self, db: AsyncSession, pk: int) -> bool:
        return await self.delete_model(db, pk)


staff_dao = StaffRepository(Salesperson)